<?php

namespace App\Imports\Fy;

use App\Models\Fy\FyRegionBankModel;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;

class FyRegionBankImport implements ToCollection
{
    /**
     * @param Collection $collection
     */
    public function collection(Collection $collection)
    {
//        $collection->shift();
        $collection->each(function ($v, $k) {
            echo "第 {$k} 行" . PHP_EOL;
            FyRegionBankModel::query()->insert([
                "bankTypeCode"   => $v->get(0),
                "regionBankCode" => $v->get(1),
                "bankNo"         => $v->get(2),
                "name"           => $v->get(3)
            ]);
        });
    }
}
